home *** CD-ROM | disk | FTP | other *** search
QuickBASIC Tokenized Source | 1989-12-04 | 1.8 KB | 30 lines |
- FileName
- Pattern
- PACKETSIZE
- PatternLength
- FileLength
- BytesLeft
- FileOffset
- Buffer
- Start
- StringPos
- FoundIt
- Default variable type is long integer.
- File to search:
- Pattern to search for: "
- Keep searching as long as there are enough bytes left in
- the file to contain the pattern you're searching for:
- Read either 10,000 bytes or the number of bytes left in the file,
- whichever is smaller, then store them in Buffer$. (If the number,
- of bytes left is less than PACKETSIZE, the following statemente
- still reads just the remaining bytes, since binary I/O doesn'te
- give "read past end" errors):
- Find every occurrence of the pattern in Buffer$:r
- Found the pattern, so print the byte position in the file
- where the pattern starts:
- Found pattern at byte number
- Find the byte position where the next I/O operation would take place,
- then back up the file pointer a distance equal to the length of the
- pattern (in case the pattern straddles a 10,000-byte boundary):
- Pattern not found.
-